package com.lims.landInfo.dao;

import javacommon.base.*;

import cn.org.rapid_framework.page.*;

import com.lims.landInfo.model.*;
import com.lims.landInfo.vo.query.*;

import static cn.org.rapid_framework.util.ObjectUtils.*;
import org.springframework.stereotype.Repository;

/**
 * @author zzh
 * @version 1.0
 * @since 1.0
 */
@Repository @SuppressWarnings("unchecked")
public class HouseRentDao extends BaseHibernateDao<HouseRent,java.lang.String>{

	
	public Class getEntityClass() {
		return HouseRent.class;
	}
	
	public Page findPage(HouseRentQuery query) {
        //XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接 
        // [column] 为PageRequest的属性
		String sql = "select t from HouseRent t where 1=1 "
			  	+ "/~ and t.sno = {sno} ~/"
			  	+ "/~ and t.landno = {landno} ~/"
			  	+ "/~ and t.lesseeNum = {lesseeNum} ~/"
			  	+ "/~ and t.contractNum = {contractNum} ~/"
			  	+ "/~ and t.safetyNum = {safetyNum} ~/"
			  	+ "/~ and t.contractUse = {contractUse} ~/"
			  	+ "/~ and t.houseArea = {houseArea} ~/"
			  	+ "/~ and t.site = {site} ~/"
			  	+ "/~ and t.rentAmount = {rentAmount} ~/"
			  	+ "/~ and t.adjustment = {adjustment} ~/"
			  	+ "/~ and t.noRentNum = {noRentNum} ~/"
			  	+ "/~ and t.fiveNum = {fiveNum} ~/"
			  	+ "/~ and t.longestTerm = {longestTerm} ~/"
			  	+ "/~ and t.litigationNum = {litigationNum} ~/"
			  	+ "/~ and t.subletNum = {subletNum} ~/"
			  	+ "/~ and t.agreedNum = {agreedNum} ~/"
			  	+ "/~ and t.oldno = {oldno} ~/"
			  	+ "/~ and t.oldContent = {oldContent} ~/"
			  	+ "/~ and t.describe = {describe} ~/"
				+ "/~ and t.landDate >= {landDateBegin} ~/"
				+ "/~ and t.landDate <= {landDateEnd} ~/"
				+ "/~ and t.createDate >= {createDateBegin} ~/"
				+ "/~ and t.createDate <= {createDateEnd} ~/"
				+ " order by t.sno asc ";

        //生成sql2的原因是为了不喜欢使用xsqlbuilder的同学，请修改生成器模板，删除本段的生成
        StringBuilder sql2 = new StringBuilder("select t from HouseRent t where 1=1 ");
        if(isNotEmpty(query.getObjid())) {
            sql2.append(" and  t.objid = :objid ");
        }
        if(isNotEmpty(query.getSno())) {
            sql2.append(" and  t.sno = :sno ");
        }
        if(isNotEmpty(query.getLandno())) {
            sql2.append(" and  t.landno = :landno ");
        }
        if(isNotEmpty(query.getLesseeNum())) {
            sql2.append(" and  t.lesseeNum = :lesseeNum ");
        }
        if(isNotEmpty(query.getContractNum())) {
            sql2.append(" and  t.contractNum = :contractNum ");
        }
        if(isNotEmpty(query.getSafetyNum())) {
            sql2.append(" and  t.safetyNum = :safetyNum ");
        }
        if(isNotEmpty(query.getContractUse())) {
            sql2.append(" and  t.contractUse = :contractUse ");
        }
        if(isNotEmpty(query.getHouseArea())) {
            sql2.append(" and  t.houseArea = :houseArea ");
        }
        if(isNotEmpty(query.getSite())) {
            sql2.append(" and  t.site = :site ");
        }
        if(isNotEmpty(query.getRentAmount())) {
            sql2.append(" and  t.rentAmount = :rentAmount ");
        }
        if(isNotEmpty(query.getAdjustment())) {
            sql2.append(" and  t.adjustment = :adjustment ");
        }
        if(isNotEmpty(query.getNoRentNum())) {
            sql2.append(" and  t.noRentNum = :noRentNum ");
        }
        if(isNotEmpty(query.getFiveNum())) {
            sql2.append(" and  t.fiveNum = :fiveNum ");
        }
        if(isNotEmpty(query.getLongestTerm())) {
            sql2.append(" and  t.longestTerm = :longestTerm ");
        }
        if(isNotEmpty(query.getLitigationNum())) {
            sql2.append(" and  t.litigationNum = :litigationNum ");
        }
        if(isNotEmpty(query.getSubletNum())) {
            sql2.append(" and  t.subletNum = :subletNum ");
        }
        if(isNotEmpty(query.getAgreedNum())) {
            sql2.append(" and  t.agreedNum = :agreedNum ");
        }
        if(isNotEmpty(query.getOldno())) {
            sql2.append(" and  t.oldno = :oldno ");
        }
        if(isNotEmpty(query.getOldContent())) {
            sql2.append(" and  t.oldContent = :oldContent ");
        }
        if(isNotEmpty(query.getDescribe())) {
            sql2.append(" and  t.describe = :describe ");
        }
        if(isNotEmpty(query.getLandDateBegin())) {
            sql2.append(" and  t.landDate >= :landDateBegin ");
        }
        if(isNotEmpty(query.getLandDateEnd())) {
            sql2.append(" and  t.landDate <= :landDateEnd ");
        }
        if(isNotEmpty(query.getCreateDateBegin())) {
            sql2.append(" and  t.createDate >= :createDateBegin ");
        }
        if(isNotEmpty(query.getCreateDateEnd())) {
            sql2.append(" and  t.createDate <= :createDateEnd ");
        }
        if(isNotEmpty(query.getSortColumns())) {
            sql2.append(" order by :sortColumns ");
        }	
        
		return pageQuery(sql,query);
	}
	

}
